package com.alibaba.citrus.ots.price.ability.functions.factory.price.process;

import com.epoch.app.otspricecenter.propertyprocess.dto.ObtainInnerCodeAndOuterCodeMapRequest;
import com.epoch.app.otspricecenter.propertyprocess.service.PropertyProcessService;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @author hanguo
 * @date 2022/1/24
 * @Description 平台编码转换服务
 */
@Service
@Primary
public class PropertyProcessServiceImpl implements PropertyProcessService {

    @Resource
    private PropertyProcessManager propertyProcessManager;


    @Override
    public Map<String, String> obtainInnerCodeAndOuterCodeMap(ObtainInnerCodeAndOuterCodeMapRequest obtainInnerCodeAndOuterCodeMapRequest) {
        PriceProcess propertyProcess = propertyProcessManager.getPropertyProcess(obtainInnerCodeAndOuterCodeMapRequest.getPropertyCode());
        if (Objects.isNull(propertyProcess)) {
            return new HashMap<>();
        }

        return propertyProcess.obtainInnerCodeAndOuterCodeMap(obtainInnerCodeAndOuterCodeMapRequest.getCodeList(),
                obtainInnerCodeAndOuterCodeMapRequest.getInnerCode());

    }
}
